import 'package:flutter/material.dart';
import 'package:flutter_easyrefresh/easy_refresh.dart';
import '../../common/ok_toast.dart';

class Test4 extends StatefulWidget{
    _TestState createState() => _TestState();
}

class _TestState extends State<Test4> {


    GlobalKey<RefreshFooterState> _footerKey = new GlobalKey<RefreshFooterState>();

    int loadMore = 20;

    @override
    Widget build(BuildContext context) {

        return new Scaffold(
            appBar: AppBar(
                title: Text("上拉下拉"),
                centerTitle: true,
            ),
            body: Container(
                child: EasyRefresh(
                    refreshFooter: ClassicsFooter(
                        key: _footerKey,
                        bgColor: Colors.white,
                        textColor: Colors.blue,
                        moreInfoColor: Colors.blue,
                        showMore: true,
                        noMoreText: "",
                        moreInfo: '加载中',
                        loadReadyText: '上拉加载···',
                        loadedText:'加载完成',
                    ),
                    child: ListView.builder(
                        itemCount: loadMore,
                        itemBuilder: (BuildContext context, int index){
                            return ListTile(
                                title:Text("${index}大标题"),
                                subtitle:Text("小标题"),
                            );
                        },
                    ),
                    loadMore: ()async{
                        setState(() {
                            loadMore = loadMore + 10;
                        });
                        OkToast.singleToast("加载更多");
                    },
                )
            ),
            
        );
    }


}
